#!/bin/bash

# 检查 can-utils 是否安装
if ! command -v cansend &> /dev/null || ! command -v candump &> /dev/null; then
    echo "can-utils 未安装，请先安装：sudo apt install can-utils"
    exit 1
fi

# 定义日志文件路径
LOG_FILE="./log/can_01tx.log"

# 激活并配置CAN接口
sudo ip link set can0 up type can bitrate 800000
sudo ip link set can1 up type can bitrate 800000

发送
while true; do
    cansend can0 123#11.22.33.44
    echo "$(date) - send message by can0: 11 22 33 44" | tee -a "$LOG_FILE"
    sleep 5
    cansend can1 123#11.22.33.44
    echo "$(date) - send message by can1: 11 22 33 44" | tee -a "$LOG_FILE"
    sleep 5
done
